<template>
    <div id="index">
        <div class="wrapper">
          <div class="title-wrapper">
            <div class="title">
                <div class="title-img">
                    <img src="../../../static/img/Sun.png">
                </div>
                <div class="title-conter">
                    早餐时间：6:00 ~ 9:00
                </div>
            </div>
            <div class="conter-list-wrapper">
                <div class="conter-list">
                    <div class="list" v-for="(item, index) in list" :key="index" :id="item.id">
                        <div class="shop">
                            <img :src="item.imgurl">
                            <div class="text">
                                {{item.title}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
          </div>
        </div>
    </div>
</template>

<script>
import apis from '../../../static/js/apis'
export default {
  components: {
    apis
  },
  data () {
    return {
      list: []
    }
  },
  created () {
    this.$axios
      .post(
        apis + '/shenglian-fast/app/weixinapp/breakfast',
        {}
      )
      .then(response => {
        if (response.data.msg === 'success') {
          let data = response.data
          this.list = data.list
        } else {
          this.$dialog.toast({mes: '数据错误，请联系管理员', timeout: 1000})
        }
      })
      .catch(error => {
        console.log(error)
        this.$dialog.toast({mes: '服务器异常，稍后再试！', timeout: 1000})
      })
  }
}
</script>

<style scoped>
.title-wrapper {
  width: 100%;
  padding: 0 8px;
  box-sizing: border-box;
  position:fixed;
  top: 0;
  bottom: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.title {
  margin: 31px auto;
  overflow: hidden;
  text-align: center;
  width: 170px;
}
.title-img {
  width: 23px;
  height: 23px;
  overflow: hidden;
  float: left;
  margin-right: 8px;
}
.title-img img {
  width: 100%;
  height: 100%;
}
.title-conter {
  float: left;
  height: 23px;
  line-height: 23px;
  font-size: 12px;
  color: #92d4ef;
}
.conter-list-wrapper {
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}
.conter-list {
  width: 100%;
  box-sizing: border-box;
}
.list {
  width: 50%;
  padding: 0 8px;
  margin-bottom: 15px;
  float: left;
  box-sizing: border-box;
}
.list:nth-child(odd) {
  flex-wrap: wrap;
}
.shop {
  height: 125px;
  overflow: hidden;
  position: relative;
}
.shop img {
  width: 100%;
  height: 100%;
}
.shop .text {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(146, 212, 239, 0.8);
  border-radius: 25px;
  padding: 7px 22px;
  font-size: 12px;
  color: #fff;
}
</style>
